package com.forum.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.forum.dao.PgdinformationDao;
import com.forum.entity.PgdInformationEntity;
import com.forum.entity.view.PgdInformationView;
import com.forum.service.PgdinformationService;
import com.forum.utils.MyQuery;
import com.forum.utils.PageUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class PgdinformationServiceImpl extends ServiceImpl<PgdinformationDao, PgdInformationEntity> implements PgdinformationService {


    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Page<PgdInformationEntity> page = this.selectPage(
                new MyQuery<PgdInformationEntity>(params).getPage(),
                new EntityWrapper<>()
        );
        return new PageUtils(page);
    }

    @Override
    public PageUtils queryPage(Map<String, Object> params, Wrapper<PgdInformationEntity> wrapper) {
        Page<PgdInformationView> page = new MyQuery<PgdInformationView>(params).getPage();
        page.setRecords(baseMapper.selectListView(page, wrapper));
        PageUtils pageUtils = new PageUtils(page);
        return pageUtils;
    }
}
